import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    isCollapse: false,
    routeTag: [
      {
        path: "/home",
        meta: {
          title: "首页",
        },
      },
    ],
  },
  getters: {
    isCollapse: (state) => {
      return state.isCollapse;
    },
  },
  mutations: {
    setCollapse(state, isCollapse) {
      state.isCollapse = isCollapse;
    },
    setrouteTag(state, to) {
      let result = false;
      for (let i = 0; i < state.routeTag.length; i++) {
        if (to.path === "/wellcome" || state.routeTag[i].path === to.path) {
          return (result = true);
        }
      }
      result === false ? state.routeTag.push(to) : "";
    },
  },
  actions: {},
  modules: {},
});
